<template>
  <div class="md:flex">
    <!---->
    <Card v-on:click="termianlListRouter"
        size="small"
        :loading="loading"
        :title="GrowCardItem[0].title"
        class="md:w-1/3 w-full !md:mt-0 !mt-4"
            :class="[index + 1 < 4 && '!md:mr-4']"
        :canExpan="false"
      >
        <template #extra>
          <Tag :color="GrowCardItem[0].color">{{ GrowCardItem[0].action }}</Tag>
        </template>

        <div class="py-4 px-40 ">
          <CountTo prefix="在线:" :startVal="1" :endVal="GrowCardItem[0].value" style="color:blue" class="text-2xl" />
<!--          <Icon :icon="item.icon" :size="40" />-->
        </div>

        <div class="p-2 px-4 flex justify-between">

          <CountTo prefix="总数:" :startVal="1" :endVal="GrowCardItem[0].total" />
        </div>
      </Card>
    <Card v-on:click="deviceListRouter"
          size="small"
          :loading="loading"
          :title="GrowCardItem[1].title"
          class="md:w-1/3 w-full !md:mt-0 !mt-4"
          :class="[index + 1 < 4 && '!md:mr-4']"
          :canExpan="false"
    >
      <template #extra>
        <Tag :color="GrowCardItem[1].color">{{ GrowCardItem[1].action }}</Tag>
      </template>

      <div class="py-4 px-40 ">
        <CountTo prefix="在线:" :startVal="1" :endVal="GrowCardItem[1].value" style="color: green" class="text-2xl" />
        <!--          <Icon :icon="item.icon" :size="40" />-->
      </div>

      <div class="p-2 px-4 flex justify-between">

        <CountTo prefix="总数:" :startVal="1" :endVal="GrowCardItem[1].total" />
      </div>
    </Card>
    <Card v-on:click="alarmReportListRouter"
          size="small"
          :loading="loading"
          :title="GrowCardItem[2].title"
          class="md:w-1/3 w-full !md:mt-0 !mt-4"
          :class="[index + 1 < 4 && '!md:mr-4']"
          :canExpan="false"
    >
      <template #extra>
        <Tag :color="GrowCardItem[2].color">{{ GrowCardItem[2].action }}</Tag>
      </template>

      <div class="py-4 px-40 ">

        <CountTo prefix="今日:" :startVal="1" :endVal="GrowCardItem[2].value" style="color: orange;" class="text-2xl" />
        <!--          <Icon :icon="item.icon" :size="40" />-->
      </div>

      <div class="p-2 px-4 flex justify-between">

        <CountTo prefix="总数:" :startVal="1" :endVal="GrowCardItem[2].total" />
      </div>
    </Card>
  </div>
<!--  <div class="md:flex">
    <template v-for="(item, index) in GrowCardItem" :key="item.title">
      <Card v-on:click="ss"
            size="small"
            :loading="loading"
            :title="item.title"
            class="md:w-1/3 w-full !md:mt-0 !mt-4"
            :class="[index + 1 < 4 && '!md:mr-4']"
            :canExpan="false"
      >
        <template #extra>
          <Tag :color="item.color">{{ item.action }}</Tag>
        </template>

        <div class="py-4 px-40 ">
          <CountTo suffix="" :startVal="1" :endVal="item.value" class="text-2xl" />
          &lt;!&ndash;          <Icon :icon="item.icon" :size="40" />&ndash;&gt;
        </div>

        <div class="p-2 px-4 flex justify-between">

          <CountTo prefix="总数:" :startVal="1" :endVal="item.total" />
        </div>
      </Card>
    </template>
  </div>-->
</template>
<script lang="ts" setup>
  import { CountTo } from '/@/components/CountTo/index';
  import { Icon } from '/@/components/Icon';
  import { Tag, Card } from 'ant-design-vue';
  import { growCardList } from '../data';
  import {defHttp} from "@/utils/http/axios";
  import { useRouter } from 'vue-router';
  const router = useRouter()
  defineProps({
    loading: {
      type: Boolean,
    },
  });
  const GrowCardItem = [
    {
      title: '终端在线情况',
      icon: 'visit-count|svg',
      value: 1,
      total: 1,
      color: 'green',
      //action: '月',
    },
    {
      title: '传感器在线情况',
      icon: 'total-sales|svg',
      value: 0,
      total: 0,
      color: 'blue',
      //action: '月',
    },
    {
      title: '局放统计',
      icon: 'download-count|svg',
      value: 0,
      total: 0,
      color: 'orange',
      // action: '周',
    },
    /*  {
        title: '成交数',
        icon: 'transaction|svg',
        value: 5000,
        total: 50000,
        color: 'purple',
      //  action: '年',
      },*/
  ];

  defHttp.get({url:"/yc/web/statisticAnalysis/growCard"}).then(data =>{
    GrowCardItem[0].value = data.loseTerminalCount;
    GrowCardItem[0].total = data.terminalCount;
    GrowCardItem[1].value = data.loseDeviceCount;
    GrowCardItem[1].total = data.deviceCount;
    GrowCardItem[2].value = data.todayAlarmCount;
    GrowCardItem[2].total = data.allAlarmCount;

    });
  function termianlListRouter(){
    router.push({path:"/yc/terminal/TerminalList"}).catch(err => {
      // 处理导航错误
      console.error(err)
    });
  }
  function deviceListRouter(){
    router.push({path:"/yc/device/YcPdDeviceList"}).catch(err => {
      // 处理导航错误
      console.error(err)
    });
  }
  function alarmReportListRouter(){
    router.push({path:"/yc/alarmReport/YcAlarmReportList"}).catch(err => {
      // 处理导航错误
      console.error(err)
    });
  }
</script>
